package com.woniuxy.service.impl;

import com.woniuxy.dao.CommunicationMapper;
import com.woniuxy.pojo.Communication;
import com.woniuxy.service.CommunicationService;
import com.woniuxy.util.DataGridView;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class CommunicationServiceImpl implements CommunicationService {
    @Autowired
    private CommunicationMapper communicationMapper;

    @Override
    public DataGridView selectCommunicationByCommCustNo(String commCustNo) {
        List<Communication> communicationsList = communicationMapper.selectCommunicationByCommCustNo(commCustNo);
        return new DataGridView(Long.valueOf(communicationsList.size()),communicationsList);
    }

    @Override
    public boolean addCommunication(Communication communication) {
        boolean flag=false;
        int count=this.communicationMapper.insertCommunication(communication);
        if(count>0){
            flag=true;
        }
        return flag;
    }

    @Override
    public Communication selectCommunicationBylinkNo(String commNo) {
        return communicationMapper.selectCommunicationByCommNo(commNo);
    }
    //删除交往记录
    @Override
    public void deleteCommunicationBycommNo(String commNo) {
        this.communicationMapper.deleteCommunication(commNo);
    }
    //批量删除交往记录
    @Override
    public void removeBatchCommunication(String[] commNos) {
        if(commNos.length>0){
            for(String commNo:commNos){
                this.deleteCommunicationBycommNo(commNo);
            }
        }
    }
    //更新交往记录
    @Override
    public void updateCommunication(Communication communication) {
        this.communicationMapper.updateCommunication(communication);
    }


}